package com.yxj.dries.data;

import androidx.annotation.WorkerThread;
import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;

import com.yxj.dries.model.User;

@Dao
public interface UserDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    @WorkerThread
    void save(User user);

    @Query("SELECT * FROM user where userId = :userId")
    LiveData<User> load(String userId);

    @Query("SELECT EXISTS(SELECT * FROM user where userId = :userId limit 1) ")
    boolean hasUser(String userId);

//    @Query("SELECT EXISTS(SELECT * FROM user where userId = :userId) ")
//    Boolean hasUser(String userId);
}
